import 'dart:ui';

Color hColor(String hexCode, {double opacity = 1.0}) {
  final hex = hexCode.replaceAll('#', '');
  // 确保字符串长度为6（RRGGBB）或8（AARRGGBB）
  if (hex.length == 6) {
    return Color(int.parse('FF$hex', radix: 16)).withOpacity(opacity);
  } else if (hex.length == 8) {
    return Color(int.parse(hex, radix: 16)).withOpacity(opacity);
  }
  throw FormatException('无效的十六进制颜色代码: $hexCode');
}
